/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.pucp.Servicio;

import java.util.ArrayList;
import pe.edu.pucp.DAO.DAOFactura;
import pe.edu.pucp.DAO.DAOServicio;
import pe.edu.pucp.DAO.MSAccessDAOFactura;
import pe.edu.pucp.bean.Servicio;


public class Servicio_ServiciosTerminal {
    public static Servicio_ServiciosTerminal instance = null;
    public static final int DB_TYPE = MSAccessDAOFactura.ACCESS;
    private ArrayList<Servicio> services = new ArrayList<Servicio>() ;
    
    protected void Service_Service(){}
    
    public static Servicio_ServiciosTerminal get_instance(){
        if(instance == null) instance = new Servicio_ServiciosTerminal();
        return instance;
    }
    
    public int editaServicio(Servicio serv){
            DAOFactura daoFactura = DAOFactura.get_instance(DB_TYPE);
            DAOServicio daoServicio = daoFactura.getDAOServicio();
            return daoServicio.update(serv);                        
    }
     public Servicio queryByServicio(String id){        
            DAOFactura daofactura = DAOFactura.get_instance(DB_TYPE);
            DAOServicio daoServicio = daofactura.getDAOServicio();
            return daoServicio.queryByIdS(id);
     }
     public int agregaServicio(Servicio serv){
	     DAOFactura daofactura = DAOFactura.get_instance(DB_TYPE);
             DAOServicio servicioDAO = daofactura.getDAOServicio();
             //services.add(serv);
             return servicioDAO.insert(serv);
     }
     public ArrayList<Servicio> queryAllServicios(){
             DAOFactura daofactura = DAOFactura.get_instance(DB_TYPE);
            DAOServicio servicioDAO =  daofactura.getDAOServicio(); //polimorfismo               
            return servicioDAO.queryAll(); 
     }
      public int eliminaServicio(String id){
             DAOFactura daofactura = DAOFactura.get_instance(DB_TYPE);
            DAOServicio daoServicio = daofactura.getDAOServicio();
            return daoServicio.delete(id);
         }
      public int agregaSerXcont(int idSer,int idCont){
            DAOFactura daofactura = DAOFactura.get_instance(DB_TYPE);
            DAOServicio servicioDAO= daofactura.getDAOServicio();
            return servicioDAO.insertServxCont(idSer, idCont);
        }
      public final ArrayList<Servicio> queryAllServxCont(String idCont){        
             DAOFactura daofactura = DAOFactura.get_instance(DB_TYPE);
            DAOServicio servicioDAO = daofactura.getDAOServicio();
            return servicioDAO.queryAllServxCont(idCont);
        }
      public final ArrayList<Servicio> queryAllSerxDoc(String idDoc){        
           DAOFactura daofactura = DAOFactura.get_instance(DB_TYPE);
            DAOServicio servicioDAO = daofactura.getDAOServicio();
            return servicioDAO.queryAllSerxDoc(idDoc);
        }
       public ArrayList<Servicio> queryByNS(String cad) {
         DAOFactura daofactura = DAOFactura.get_instance(DB_TYPE);
            DAOServicio daoServicio = daofactura.getDAOServicio();
            return daoServicio.queryByNS(cad);
    }
}
